# @Time    :2025/3/22 22:12
"""
    该案例演示了while循环
    需求：第1周有2只兔子，此后每周兔子的数量都增加上周数量的2倍，且期间没有兔子死亡，求第10周共有多少只兔子：
"""
# week = 1
# rabbit = 2
# while week < 10:
#     rabbit = rabbit * 3
#     week += 1
#
# print(f"第{week} 周的兔子数量是: {rabbit}")
#
# week = 1
# rabbit = 2
# while week < 10:
#     rabbit = rabbit * 3
#     week += 1
#     if week == 5:
#         break
# else:
#     print(f"第{week} 周的兔子数量是:{rabbit}")  #这句不会被打印，因为前边给break了
#
#
# 打印进度条
import time

num = 1
while num < 100:
    print("\r" + "=" * num, end="")  # \r 覆盖掉前包的内容，比如 当num=5时，"="*num  结果就是"====="，end="" 是确保每次打印不换行
    num += 1
    time.sleep(0.8)
